
from tkinter import *
from tkinter.ttk import *

class WinGUI(Tk):
    def __init__(self):
        super().__init__()
        self.__win()
        self.tk_label_m3719e0q = self.__tk_label_m3719e0q(self)
        self.tk_label_m3719oj6 = self.__tk_label_m3719oj6(self)
        self.tk_table_data_list = self.__tk_table_data_list(self)
        self.tk_label_m371atvm = self.__tk_label_m371atvm(self)
        self.tk_label_m371btvf = self.__tk_label_m371btvf(self)
        self.tk_button_m371c3ii = self.__tk_button_m371c3ii(self)
        self.tk_label_m371kviz = self.__tk_label_m371kviz(self)
        self.tk_label_m371low2 = self.__tk_label_m371low2(self)
        self.tk_input_m371mc8q = self.__tk_input_m371mc8q(self)
        self.tk_label_m371mg4z = self.__tk_label_m371mg4z(self)
        self.tk_input_m371mumr = self.__tk_input_m371mumr(self)
        self.tk_label_m371ozg3 = self.__tk_label_m371ozg3(self)
        self.tk_label_m371ystv = self.__tk_label_m371ystv(self)
        self.tk_input_m371z7ob = self.__tk_input_m371z7ob(self)
        self.tk_label_m372126q = self.__tk_label_m372126q(self)
        self.tk_button_m371myqb = self.__tk_button_m371myqb(self)
        self.tk_button_m371myde = self.__tk_button_m371myde(self)
        #新增的  1.0.4
        self.tk_label_m4cgz7ls = self.__tk_label_m4cgz7ls(self)
        self.tk_input_m4cgza27 = self.__tk_input_m4cgza27(self)
        self.tk_label_m4cgzugg = self.__tk_label_m4cgzugg(self)
        self.tk_input_m4cgzy5s = self.__tk_input_m4cgzy5s(self)
        self.tk_label_m4ch014w = self.__tk_label_m4ch014w(self)
        self.tk_input_m4ch02ls = self.__tk_input_m4ch02ls(self)
        self.tk_label_m4ch04p4 = self.__tk_label_m4ch04p4(self)
        self.tk_input_m4ch06iw = self.__tk_input_m4ch06iw(self)
        self.tk_label_m4ch07yg = self.__tk_label_m4ch07yg(self)
        self.tk_input_m4ch09if = self.__tk_input_m4ch09if(self)
        self.tk_label_m4ch0bsg = self.__tk_label_m4ch0bsg(self)
        self.tk_input_m4ch0e3z = self.__tk_input_m4ch0e3z(self)
        self.tk_label_m4ch0g20 = self.__tk_label_m4ch0g20(self)
        self.tk_input_m4ch0hh4 = self.__tk_input_m4ch0hh4(self)
        self.tk_button_m4chq0q0 = self.__tk_button_m4chq0q0(self)
        self.tk_button_m4chq9qv = self.__tk_button_m4chq9qv(self)

    def __win(self):
        self.title("时间计算推送_v1.0.4")
        # 设置窗口大小、居中
        width = 740
        height = 632
        screenwidth = self.winfo_screenwidth()
        screenheight = self.winfo_screenheight()
        geometry = '%dx%d+%d+%d' % (width, height, (screenwidth - width) / 2, (screenheight - height) / 2)
        self.geometry(geometry)
        self.resizable(width=False, height=False)
        
    def scrollbar_autohide(self,vbar, hbar, widget):
        """自动隐藏滚动条"""
        def show():
            if vbar: vbar.lift(widget)
            if hbar: hbar.lift(widget)
        def hide():
            if vbar: vbar.lower(widget)
            if hbar: hbar.lower(widget)
        hide()
        widget.bind("<Enter>", lambda e: show())
        if vbar: vbar.bind("<Enter>", lambda e: show())
        if vbar: vbar.bind("<Leave>", lambda e: hide())
        if hbar: hbar.bind("<Enter>", lambda e: show())
        if hbar: hbar.bind("<Leave>", lambda e: hide())
        widget.bind("<Leave>", lambda e: hide())
    
    def v_scrollbar(self,vbar, widget, x, y, w, h, pw, ph):
        widget.configure(yscrollcommand=vbar.set)
        vbar.config(command=widget.yview)
        vbar.place(relx=(w + x) / pw, rely=y / ph, relheight=h / ph, anchor='ne')
    def h_scrollbar(self,hbar, widget, x, y, w, h, pw, ph):
        widget.configure(xscrollcommand=hbar.set)
        hbar.config(command=widget.xview)
        hbar.place(relx=x / pw, rely=(y + h) / ph, relwidth=w / pw, anchor='sw')
    def create_bar(self,master, widget,is_vbar,is_hbar, x, y, w, h, pw, ph):
        vbar, hbar = None, None
        if is_vbar:
            vbar = Scrollbar(master)
            self.v_scrollbar(vbar, widget, x, y, w, h, pw, ph)
        if is_hbar:
            hbar = Scrollbar(master, orient="horizontal")
            self.h_scrollbar(hbar, widget, x, y, w, h, pw, ph)
        self.scrollbar_autohide(vbar, hbar, widget)
    def __tk_label_m3719e0q(self,parent):
        label = Label(parent,text="当前时间：",anchor="center", )
        label.place(x=1, y=1, width=84, height=30)
        return label
    def __tk_label_m3719oj6(self,parent):
        label = Label(parent,text="2024-11-07 16:16:16",anchor="center", )
        label.place(x=86, y=1, width=324, height=30)
        return label
    def __tk_table_data_list(self,parent):
        # 表头字段 表头宽度
        columns = {"ID":73,"名称":146,"农历":109,"月份":109,"日期":109,"状态":109,"启用":73}
        tk_table = Treeview(parent, show="headings", columns=list(columns))
        """
            定义滚动条控件
            orient为滚动条的方向，vertical--纵向，horizontal--横向
            command=self.tree.yview 将滚动条绑定到treeview控件的Y轴
        """
        VScroll1 = Scrollbar(tk_table, orient='vertical', command=tk_table.yview)
        VScroll1.place(relx=0.980, rely=0.008, relwidth=0.024, relheight=0.958)
        # 给treeview添加配置
        tk_table.configure(yscrollcommand=VScroll1.set)

        for text, width in columns.items():  # 批量设置列属性
            tk_table.heading(text, text=text, anchor='center')
            tk_table.column(text, anchor='center', width=width, stretch=False)  # stretch 不自动拉伸
        tk_table.place(x=0, y=77, width=740, height=256)
        return tk_table
    def __tk_label_m371atvm(self,parent):
        label = Label(parent,text="运行状态：",anchor="center", )
        label.place(x=1, y=40, width=84, height=30)
        return label
    def __tk_label_m371btvf(self,parent):
        label = Label(parent,text="暂未运行",anchor="center", )
        label.place(x=86, y=40, width=250, height=30)
        return label
    def __tk_button_m371c3ii(self,parent):
        btn = Button(parent, text="开始", takefocus=False,)
        btn.place(x=351, y=40, width=124, height=30)
        return btn
    def __tk_label_m371kviz(self,parent):
        label = Label(parent,text="运行上报：",anchor="center", )
        label.place(x=0, y=344, width=85, height=30)
        return label
    def __tk_label_m371low2(self,parent):
        label = Label(parent,text="链接地址：",anchor="center", )
        label.place(x=1, y=384, width=73, height=30)
        return label
    def __tk_input_m371mc8q(self,parent):
        ipt = Entry(parent, )
        ipt.place(x=82, y=384, width=630, height=30)
        return ipt
    def __tk_label_m371mg4z(self,parent):
        label = Label(parent,text="User-Agent:",anchor="center", )
        label.place(x=1, y=425, width=87, height=30)
        return label
    def __tk_input_m371mumr(self,parent):
        ipt = Entry(parent, )
        ipt.place(x=82, y=426, width=630, height=30)
        return ipt
    def __tk_button_m371myqb(self, parent):
        btn = Button(parent, text="添加一列", takefocus=False, )
        btn.place(x=352, y=344, width=124, height=30)
        return btn
    def __tk_button_m371myde(self, parent):
        btn = Button(parent, text="删除", takefocus=False, )
        btn.place(x=500, y=344, width=124, height=30)
        return btn
    def __tk_label_m371ozg3(self,parent):
        label = Label(parent,text="运行时间：0天0小时0分钟0秒",anchor="center", )
        label.place(x=500, y=40, width=200, height=30)
        return label
    def __tk_label_m371ystv(self,parent):
        label = Label(parent,text="钉钉机器链接：",anchor="center", )
        label.place(x=2, y=473, width=101, height=30)
        return label
    def __tk_input_m371z7ob(self,parent):
        ipt = Entry(parent, )
        ipt.place(x=108, y=469, width=605, height=30)
        return ipt
    def __tk_label_m372126q(self,parent):
        label = Label(parent,text="暂无上报",anchor="center", )
        label.place(x=90, y=344, width=235, height=30)
        return label

    # 新增的  1.0.4
    def __tk_label_m4cgz7ls(self,parent):
        label = Label(parent,text="钉钉密匙：",anchor="center", )
        label.place(x=2, y=511, width=63, height=30)
        return label
    def __tk_input_m4cgza27(self,parent):
        ipt = Entry(parent, )
        ipt.place(x=71, y=511, width=634, height=30)
        return ipt
    def __tk_label_m4cgzugg(self,parent):
        label = Label(parent,text="提前几天：",anchor="center", )
        label.place(x=2, y=551, width=64, height=30)
        return label
    def __tk_input_m4cgzy5s(self,parent):
        ipt = Entry(parent, )
        ipt.place(x=72, y=551, width=80, height=30)
        return ipt
    def __tk_label_m4ch014w(self,parent):
        label = Label(parent,text="计算频率：",anchor="center", )
        label.place(x=2, y=590, width=64, height=30)
        return label
    def __tk_input_m4ch02ls(self,parent):
        ipt = Entry(parent, )
        ipt.place(x=74, y=590, width=80, height=30)
        return ipt
    def __tk_label_m4ch04p4(self,parent):
        label = Label(parent,text="开始时间：",anchor="center", )
        label.place(x=166, y=549, width=64, height=30)
        return label
    def __tk_input_m4ch06iw(self,parent):
        ipt = Entry(parent, )
        ipt.place(x=232, y=549, width=80, height=30)
        return ipt
    def __tk_label_m4ch07yg(self,parent):
        label = Label(parent,text="结束时间：",anchor="center", )
        label.place(x=341, y=553, width=64, height=30)
        return label
    def __tk_input_m4ch09if(self,parent):
        ipt = Entry(parent, )
        ipt.place(x=408, y=552, width=80, height=30)
        return ipt
    def __tk_label_m4ch0bsg(self,parent):
        label = Label(parent,text="清零时间：",anchor="center", )
        label.place(x=169, y=588, width=64, height=30)
        return label
    def __tk_input_m4ch0e3z(self,parent):
        ipt = Entry(parent, )
        ipt.place(x=234, y=589, width=80, height=30)
        return ipt
    def __tk_label_m4ch0g20(self,parent):
        label = Label(parent,text="清零时间：",anchor="center", )
        label.place(x=342, y=589, width=64, height=30)
        return label
    def __tk_input_m4ch0hh4(self,parent):
        ipt = Entry(parent, )
        ipt.place(x=411, y=589, width=80, height=30)
        return ipt
    def __tk_button_m4chq0q0(self,parent):
        btn = Button(parent, text="修改配置", takefocus=False,)
        btn.place(x=508, y=559, width=86, height=56)
        return btn
    def __tk_button_m4chq9qv(self,parent):
        btn = Button(parent, text="查看日志", takefocus=False,)
        btn.place(x=618, y=559, width=86, height=56)
        return btn

class Win(WinGUI):
    def __init__(self, controller):
        self.ctl = controller
        super().__init__()
        self.__event_bind()
        self.__style_config()
        self.ctl.init(self)
    def __event_bind(self):
        self.tk_button_m371c3ii.bind('<Button-1>',self.ctl.birthdayCalculation)
        self.tk_button_m371myqb.bind('<Button-1>',self.ctl.on_double_add)
        self.tk_button_m371myde.bind('<Button-1>',self.ctl.on_double_del)
        self.tk_table_data_list.bind("<Double-1>", self.ctl.on_double_click)
        self.tk_button_m4chq0q0.bind("<Button-1>", self.ctl.saveKey)
        self.tk_button_m4chq9qv.bind("<Button-1>", self.ctl.newPage)
        pass
    def __style_config(self):
        pass
if __name__ == "__main__":
    win = WinGUI()
    win.mainloop()